package tcu.ead.leety.tcuplant.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tcu.ead.leety.tcuplant.common.QuerySwitchUtils;
import tcu.ead.leety.tcuplant.common.R;
import tcu.ead.leety.tcuplant.service.HttpService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RestController
@RequestMapping("/tcuplant")
public class HttpController {

    @Resource
    private HttpService httpService;

    @CrossOrigin
    @GetMapping(value = "/list")
    public R getTreeInfo(HttpServletRequest request) {
        String id = QuerySwitchUtils.QuerySwitch(request.getQueryString());

        return httpService.getHttpData(Integer.parseInt(id));
    }
}
